<?php

declare(strict_types=1);

namespace App\Request\Backend\Admin;

use Hyperf\Validation\Request\FormRequest;

class AdminEditRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'user_name' => 'required',
            // 'login_name' => 'required|unique:admins',
            'avatar' => 'required|url',
            'id' => 'required|numeric',
            'role_id' => 'required',
            'password' => 'min:8',
        ];
    }

    public function messages(): array
    {
        return [
            'user_name.required' => '用户名称必填',
            'login_name.required' => '登录用户名必填',
            'avatar.required' => '头像必传',
            'role_id.required' => '角色必选',
            'login_name.unique' => '登录用户名已存在',
        ];
    }
}
